package org.itworks.biodev.model;

public class ProductSubCategory {
	private Integer id;
	private String label;
	private ProductCategory category = null;
	private int category_id;
	
	public ProductSubCategory() {
		
	}

	public Integer getId() {
		return id;
	}
	
	public void setId(int id) {
		this.id = id;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public ProductCategory getCategory() throws Exception {
		if(category == null) {
			category = ProductSubCategoryTable.getInstance().findCategoryFromSubCategory(this);
		}
		return category;
	}

	public void setCategory(ProductCategory category) {
		this.category = category;
		this.category_id = category.getId();
	}
	
	public int getCategoryId() {
		return this.category_id;
	}
	
	public void setCategoryId(int id) {
		this.category_id = id;
		this.category = null;
	}
}
